Skip to content

Various formatting fixes - #101

Merged
Rigidity merged 3 commits into
mainfrom
formatter-fixes
Jul 27, 2026
Merged

Various formatting fixes#101
Rigidity merged 3 commits into
mainfrom
formatter-fixes

Conversation

@Rigidity

@Rigidity Rigidity commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Note

Medium Risk
Changes core whitespace/comment emission and import-group layout, which can alter formatted output broadly; risk is mitigated by large idempotent snapshot tests but not zero for edge-case sources.

Overview
Refactors formatter internals so whitespace and comments are modeled as Gap values instead of a Trivia wrapper, and widens several pub(crate) APIs (Layout, Doc, TokenStream, planning types, etc.) for reuse. Shared helpers move onto TokenStream (matching_brace) and token_stream (significant_tokens); Gap gains dangling(), ends_line(), and trivia splitting returns plain gaps (including capping trailing newlines when only inline comments remain).

Emitting now routes through gap_doc / Separator::after so trailing line comments and multiline gaps don’t swallow blank lines between top-level items, fixes inline comment spacing when a gap ends without a following newline, and reworks nested import { … } layout (opening trivia, separators between paths, trailing commas when comments sit before commas, closing-brace line handling).

Adds broad regression coverage for comments (EOF, CRLF, postfix/conditional branches), import sorting/comment ownership, and mixed syntax shapes in a new regressions test module.

Reviewed by Cursor Bugbot for commit 5077773. Bugbot is set up for automated code reviews on this repo. Configure here.

@Rigidity Rigidity changed the title Formatter fixes Fixes for comments attached to re-ordered imports Jul 27, 2026
@Rigidity Rigidity changed the title Fixes for comments attached to re-ordered imports Various formatting fixes Jul 27, 2026
@Rigidity
Rigidity merged commit 5f7f7b6 into main Jul 27, 2026
2 checks passed
@Rigidity
Rigidity deleted the formatter-fixes branch July 27, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant